package com.lhk;

import com.lhk.entity.student;
import com.lhk.mapper.studentMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.HashMap;
import java.util.List;

@SpringBootTest
class MybatisPlusApplicationTests {
	@Autowired
	private studentMapper studentMapper;
	@Test
	void contextLoads() {
		System.out.println(("----- selectAll method test ------"));//输出提示
		List<student> students = studentMapper.selectList(null);
		//Wrapper代表一个参数，相当于表查询时候的条件，这里填写为null，相当于查询全部。
		students.forEach(System.out::println); //打印出来
	}
	@Test
	//条件查询
	public void testSelectByBatchIds(){
		HashMap<String, Object> map = new HashMap<>(); //新建一个map，从一个String对象映射来
		//自定义查询
		map.put("sname","John");
		List<student> students = studentMapper.selectByMap(map);//通过map来做简单的查询
		students.forEach(System.out::println); //打印出来
	}



}
